-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to choose python-for-android directory #60
Conversation
Why using a env variable instead of a config token ? (i think i know the answer, but i want to see if you think the same as me. And if you do, the issue is more general than this need, and then, should be generalized instead). Also, documentation must be updated to talk about this one. |
My reasons were:
Of course, there are disadvantages to these as well, I honestly didn't know which way would be best. |
Why not have a config token that can be superseded by an environment variable if one exists? |
That would fix some things, but leaves the minor problem of failures on different system if the env var doesn't exist but the config token does. Of course, you could solve that too by checking if the config token directory exists and cloning p4a if it doesn't. Or maybe that problem isn't important. I thought about stuff like this, but I didn't like it because it adds an extra layer of complexity and implicit behaviour. I'm not saying it's necessarily a bad idea though! Just that's why I didn't start off that way. |
@inclement good. :) I ended up my thinking at the same point as broush: globally, all the config token could be superseded by env, in the syntax SECTION_TOKEN=VALUE (we could even prefix them with P4A_ to avoid collision). And then, leave the config token to blank if you don't want to use it. If it's commited with a specific path (using relative path would be good i guess, while make less-sense if it's using the directory of an user for example), then it's up to you to tell the original user to leave it blank, or set the associated env to blank as well. This way, we have a global approach for overriding all the tokens. :) |
The new method replaces the manual env var parsing with simply setting the config's value to the env var value. This lets the normal parsing methods do the work later, to avoid duplication of effort.
I've pushed some changes that give this behaviour. When the ConfigParser is created, buildozer now checks every existing section and token for an env var of the form SECTION_TOKEN, with dots replaced by underscores, and uses it to set the ConfigParser variable if the env var exists. It also checks for an env var when a token is accessed (e.g. with getdefault), in case the section/token didn't exist in the original config but does exist as an env var. I also added android.p4a_dir as a buildozer token, which can of course be overridden with $ANDROID_P4A_DIR. Is this method the right way of doing it? My main concern is whether there should be more env checking attached to the token querying of the ConfigParser; at the moment, and environment variable is only checked if the token exists in buildozer.spec or if if is accessed with the monkey-patched This isn't currently a problem (and may never be), as the config is only accessed with |
Anyone have comments on this? I'd like to add documentation and submit it to be merged if the general idea is as you both wanted. |
Add ability to choose python-for-android directory
Good! |
(Edit: Following updates, the PR now creates a full system for setting buildozer options with env vars. See later comments for discussion).
This PR makes buildozer check for an environment variable, $BUILDOZER_P4A_DIR . If the variable exists, buildozer creates a symlink to this directory instead of cloning into the python-for-android github master.
Since this would cause problems with multiple apps repeatedly overwriting the p4a default distribution, the pr also changes the behaviour so that buildozer creates a distribution with the same name as app.package.name in the buildozer.spec file. This seems safe, since this already has to be something simple or build.py fails, but I'm not totally sure. The result is that any number of apps can safely share the same p4a clone as long as they have different names.
A final change as part of this is that buildozer no longer runs
git clean -dxf
before distribute.sh, in order to avoid removing the dist folders for any other apps using the same python-for-android. I'm not sure if this change is important...it seems like the clean shouldn't be necessary. Maybe I should add it as a buildozer option in the command line?